<?php	
	// Interface function	
	function oh_module_pagemanage($tokens) {	
		global $oh_object_pagemanage;
		if (count($tokens)>0) {
			oh_dump($oh_object_pagemanage->this());
		}	
		return $oh_object_pagemanage;
	} 		

	// Option file required
	require_once($oh['path']."/modules/pagemanage/pagemanage.class.php");
		
	// Main class of module
	class oh_class_pagemanage extends the_pagemanage {
		public $rules;
		function oh_class_pagemanage() {
			$this->rules = array(
			
			);
		}
		function add_rule($key, $rule) {
			global $oh_object_pagemanage;
			$this->rules[] = array("key"=>$key,"rule"=>$rule);
			return $oh_object_pagemanage;
		}
		function get_TURL() {
			$u = $_SERVER["REQUEST_URI"];
			if (strpos($u,"?") !== FALSE) {
			//	echo substr($u,0,strpos($u,"?"));
				$e = substr($u,0,strpos($u,"?"));
			} else {
			//	echo $u;
				$e = $u;
			}
			//echo '<br>';
			//echo dirname($_SERVER["SCRIPT_NAME"]);	
			$d = dirname($_SERVER["SCRIPT_NAME"]);	
			//echo '<br>';
			$r = substr($e,strlen($d));
			$r = explode("/",$r);
			$TGET = $_GET;
			$TURL = $_GET;
			foreach($r as $t) {
				if (strlen($t)>0) {
					$TURL[] = $t;
				}
			}
			return $TURL;
		} 

		function this() {
			$page = array();
			foreach($this->rules as $i=>$row) {
				if (false) {
				} else if ($this->have_on_URL ($i,$row["key"],$row["rule"]))	{
					$page[$row["key"]] = 
						$this->load_from_URL 
							($i,$row["key"],$row["rule"]);
			
				} else if ($this->have_on_POST($i,$row["key"],$row["rule"]))	{
					$page[$row["key"]] = 
						$this->load_from_POST
							($i,$row["key"],$row["rule"]);
			
				} else if ($this->have_on_GET ($i,$row["key"],$row["rule"]))	{
					$page[$row["key"]] = 
						$this->load_from_GET 
							($i,$row["key"],$row["rule"]);
			
				} else {
					//$page[$row["key"]] = (String)$row["rule"];
				}
			}
			if (count($page)==0) {
				$page['home'] = array();
			}
			return $page;
		}
	}
	
	// Main object of module
	global $oh_object_pagemanage;
	$oh_object_pagemanage = new oh_class_pagemanage();
?>
